export default{
    state: {//存放共享数据
        //当前菜单
        currentMenu:null,
        isCollapse:false,
        //定义数组,存放左侧菜单
        tabsList:[
            {
                path:'/home',
                label:'首页',
                name:'home',
                icon:'s-home'
            }
        ]
    },
    mutations: {//存放方法
        selectMenu(state,val){
            //面包屑 tag选项标签
            if(val.name === 'home'){
                state.currentMenu=null
            }else{
                state.currentMenu=val
                //如果等于-1 那么就说明数组中不存在这个对象,那么就直接插入,否则就什么都不做
                let result = state.tabsList.findIndex(item => item.name === val.name)
                result === -1 ? state.tabsList.push(val) :''
            }
            //val.name === 'home' ? (state.currentMenu=null) : (state.currentMenu=val)
        },
        //点击删除节点
        closeTab(state,val) {
            let result = state.tabsList.findIndex(item => item.name === val.name)
            state.tabsList.splice(result,1)
        },
        collapseMenu(state){
            state.isCollapse=!state.isCollapse
        }

    },
    actions: {//异步改变

    },
}